<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/WEB-INF/jsp/importHead.jsp"%>
<%@ include file="/WEB-INF/jsp/importCommonCss.jsp"%>
<link rel="stylesheet" type="text/css" href="${basePath }/css/index-old.css" />
<style>
body.met-navfixed {
	margin: 0 auto;
	padding: 0;
	height: 100%;
	padding-top: 65px;
	min-height: 595px;
}

html {
	margin: 0 auto;
	padding: 0;
	height: 100%;
	min-height: 595px;
	position: relative;
}

html, body {
	margin: 0px;
	height: 100%;
}

body.met-navfixed>section.notice_list_met_11_1 {
	visibility: inherit;
	opacity: 1;
	transform: matrix(1, 0, 0, 1, 0, 0);
	background-color: #F5F5F5;
}

body.met-navfixed>section.notice_list_met_11_1 div.container.notice {
	height: auto;
	line-height: normal;
}

div.form-group>label.form-control-label {
	height: auto;
	line-height: normal;
}

footer.foot_info_met_16_1 {
	background-color: #F5F5F5;
	width: 100%;
}

.red {
	color: red;
}

form.form-horizontal button.btn{
    padding-left: 1.5em;
    padding-right: 1.5em;
    border-radius: 5px;
}

#errorMessageContent label.form-control-label {
    height: 2.573rem;
}
</style>

</head>

<body class="met-navfixed">
	<%@ include file="/WEB-INF/jsp/otherUser/commonHeader.jsp"%>
	
	<section class="notice_list_met_11_1 text-xs-left" m-id="4">
	<div class="container notice clearfix" style="min-height: 532px; min-width: 600px;padding: 20px 130px 40px 130px;">
			<div class="container-fluid" style="border-bottom: 1px #dcdcdc dashed;padding-bottom: 20px;">
				<h1><i class="icon wb-search"></i>找回密码</h1><p>如果您在登录本系统时提示密码错误而无法登陆时，请填写我们的密码找回申请，找回您的登陆密码</p>
			</div>
			
			<div class="container-fluid" style="border-bottom: 1px #dcdcdc dashed;padding-top: 50px;padding-bottom: 50px;">
				<form action="${basePath }/changeByEmail" method="post" id="changeForm" class="form-horizontal container">
					<input type="hidden" name="uuid" value="${uuid }">
					<div class="container-fluid form-group">
						<label class="col-xs-3 form-control-label">
							注册邮箱：
						</label>
						<div class="col-xs-4">
							<input type="text" id="formInput" name="email" class="form-control" maxlength="20" />
						</div>
						<label class="form-control-label pull-left text-xs-left col-xs-5 red" style="padding-left: 0;display: none;" id="errorMsg">
							
						</label>
					</div>
					
					<div class="form-group text-xs-center">
						<button class="btn btn-primary" type="button" id="submitBtn" style="padding-left: 41px;padding-right: 41px;">下一步</button>		
					</div>
				</form>
			</div>
			
	</div>
	<%@ include file="/WEB-INF/jsp/importFooter.jsp"%>
	<%@ include file="/WEB-INF/jsp/importCommonJS.jsp"%>
	<%@ include file="/WEB-INF/jsp/manage/importCommonJS.jsp"%>
	
	<script>
		$(function(){
			$("#submitBtn").bind("click",function(){
				var email = $("#changeForm")[0].email.value;
				if(email.replace(/(^\s+)|(\s+$)/g,'').length > 0){
					$.ajax({
						url: "${basePath}/checkEmail",
						type: "post",
						data: {email: email,uuid: $("#changeForm")[0].uuid.value},
						dataType: "text",
						success: function(data){
							if(data == "success"){
								$("#changeForm")[0].submit();
							}
							else if(data == "EM_NE"){
								showErrorMessage("您输入的邮箱与您注册的邮箱不一致");
							}
							else if(data == "EM_EN"){
								showErrorMessage("该邮箱对应的用户并不存在，请重试");
							}
							else{
								showErrorMessage("连接服务器发生未知错误");
							}
						},
						error: function(){
							showErrorMessage("连接服务器发生未知错误");
						},
						timeout: function(){
							showErrorMessage("连接服务器超时，请检查网络");
						}
					});
				}
				else{
					showErrorMessage("请输入注册邮箱");
				}
			});
			
			$("#formInput").bind("focus",function(){
				$("#errorMsg").hide();
			});
		});
		
		var showErrorMessage = function(text){
			$("#errorMsg").text(text);
			$("#errorMsg").show();

			var timeout = setTimeout(function() {
				$("#errorMsg").hide();
			}, 5000);
		}
	</script>
</body>
</html>
